<template>
  <el-container class="home_container">
    <!-- 头部 -->
    <el-header>
      <div>
        <img src="@/assets/heima.png" alt="" />
        <span>后台管理系统</span>
      </div>
      <el-button type="info" @click="loginOut">退出登录</el-button>
    </el-header>
    <!-- 主体 -->
    <el-container>
      <!-- 侧边栏 -->
      <el-aside :width="isColl ? '64px' : '200px'">
        <my-aside @toggleMenu="getToggle"></my-aside>
      </el-aside>
      <!-- 右侧主体 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import MyAside from '@/components/Aside.vue'
export default {
  name: 'Home',
  data() {
    return {
      isColl: false,
    }
  },
  components: {
    MyAside,
  },
  methods: {
    // 退出登录
    loginOut() {
      window.sessionStorage.removeItem('token')
      this.$router.push('/login')
    },
    // 得到子组件传过来的值 根据这个值按需改变侧边栏的宽度
    getToggle(howWidth) {
      // console.log(howWidth)
      this.isColl = howWidth
    },
  },
}
</script>

<style lang="less" scoped>
.home_container {
  height: 100%;
}
.el-header {
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  background-color: #373d41;
  align-items: center;
  color: #fff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    span {
      margin-left: 15px;
    }
  }
}
.el-aside {
  background-color: #333744;
}
.el-main {
  background-color: #eaedf1;
}
</style>
